package com.example.summary.lianbiao;

/**
 * Created by wzn on 2019/3/29.
 */
public class LianBIaoDeleteChongfu {

    public static void main(String[] args) {
        LianBiaoNode node = new LianBiaoNode(1, new LianBiaoNode(1, new LianBiaoNode(1
                , new LianBiaoNode(7
                , new LianBiaoNode(8, new LianBiaoNode(8
                , new LianBiaoNode(9, new LianBiaoNode(9
                , new LianBiaoNode(10, new LianBiaoNode(10, null))))))))));
        delete(node);
        while (null != node) {
            System.out.println(node.getI());
            node = node.getNext();
        }
    }

    private static LianBiaoNode delete(LianBiaoNode node) {
        if (node.getNext() != null) {
            LianBiaoNode delete = delete(node.getNext());
            if (node.getI() == node.getNext().getI()) {
                node.setNext(delete);
            }
        }
        return node.getNext();
    }
}
